OVERWORLDS_DIR := $(BUILD)/pokemonow
OVERWORLDS_NARC := $(BUILD_NARC)/0/8/1
OVERWORLDS_DEPENDENCIES_DIR := data/graphics/overworlds

OVERWORLDS_SRCS := $(wildcard $(OVERWORLDS_DEPENDENCIES_DIR)/*.png) $(wildcard $(OVERWORLDS_DEPENDENCIES_DIR)/*.bin) $(wildcard $(OVERWORLDS_DEPENDENCIES_DIR)/*.json) $(wildcard $(OVERWORLDS_DEPENDENCIES_DIR)/*.pal)
#OVERWORLDS_SRCS := $(filter-out $(wildcard $(OVERWORLDS_DEPENDENCIES_DIR)/*_shiny.png),$(OVERWORLDS_SRCS))
OVERWORLDS_OBJS := $(patsubst $(OVERWORLDS_DEPENDENCIES_DIR)/%.png,$(OVERWORLDS_DIR)/1_%.btx0,$(OVERWORLDS_SRCS)) $(patsubst $(OVERWORLDS_DEPENDENCIES_DIR)/%.bin,$(OVERWORLDS_DIR)/1_%.bin,$(OVERWORLDS_SRCS))
#OVERWORLDS_OBJ_FILTERS := $(patsubst $(OVERWORLDS_DEPENDENCIES_DIR)/%.png,$(OVERWORLDS_DIR)/3_%,$(OVERWORLDS_SRCS))

# add your own overworld sources here
ALL_OVERWORLDS_SRCS := $(OVERWORLDS_SRCS)
ALL_OVERWORLDS_OBJS := $(OVERWORLDS_OBJS)

#$(OVERWORLDS_DIR)/2_%_shiny:$(OVERWORLDS_DEPENDENCIES_DIR)/%_shiny.png
#	@:

$(OVERWORLDS_DIR)/1_%.btx0:$(OVERWORLDS_DEPENDENCIES_DIR)/%.png $(OVERWORLDS_DEPENDENCIES_DIR)/%.json $(OVERWORLDS_DEPENDENCIES_DIR)/%*.pal
	$(BTX) $< $@

$(OVERWORLDS_DIR)/1_%.bin:$(OVERWORLDS_DEPENDENCIES_DIR)/%.bin
	cp -f $< $@

#$(OVERWORLDS_NARC): $(ALL_OVERWORLDS_SRCS) | overworld_extract $(ALL_OVERWORLDS_OBJS)
$(OVERWORLDS_NARC): $(ALL_OVERWORLDS_SRCS) $(ALL_OVERWORLDS_OBJS)
	$(NARCHIVE) -d $(OVERWORLDS_DIR) -p $@

NARC_FILES += $(OVERWORLDS_NARC)

TRAINER_GFX_DIR := $(BUILD)/trainer_gfx
TRAINER_GFX_NARC := $(BUILD_NARC)/0/5/8
TRAINER_GFX_DEPENDENCIES_DIR := data/graphics/trainer_gfx
TRAINER_GFX_DEPENDENCIES := $(TRAINER_GFX_DEPENDENCIES_DIR)/*

TRAINER_GFX_PICS := $(wildcard $(TRAINER_GFX_DEPENDENCIES_DIR)/*_enc.png)
TRAINER_GFX_NCGR := $(patsubst $(TRAINER_GFX_DEPENDENCIES_DIR)/%_enc.png,$(TRAINER_GFX_DIR)/8_%-00.NCGR,$(TRAINER_GFX_PICS))
TRAINER_GFX_PALS := $(patsubst $(TRAINER_GFX_DEPENDENCIES_DIR)/%_enc.png,$(TRAINER_GFX_DIR)/8_%-01.NCLR,$(TRAINER_GFX_PICS))
TRAINER_GFX_NCER := $(patsubst $(TRAINER_GFX_DEPENDENCIES_DIR)/%_enc.png,$(TRAINER_GFX_DIR)/8_%-02.NCER,$(TRAINER_GFX_PICS))
TRAINER_GFX_NANR := $(patsubst $(TRAINER_GFX_DEPENDENCIES_DIR)/%_enc.png,$(TRAINER_GFX_DIR)/8_%-03.NANR,$(TRAINER_GFX_PICS))
TRAINER_GFX_NCBR := $(patsubst $(TRAINER_GFX_DEPENDENCIES_DIR)/%_enc.png,$(TRAINER_GFX_DIR)/8_%-04.NCGR,$(TRAINER_GFX_PICS))
TRAINER_GFX_OBJS := $(TRAINER_GFX_NCGR) $(TRAINER_GFX_PALS) $(TRAINER_GFX_NCER) $(TRAINER_GFX_NANR) $(TRAINER_GFX_NCBR)

$(TRAINER_GFX_DIR)/8_%-00.NCGR:$(TRAINER_GFX_DEPENDENCIES_DIR)/%.png
	@mkdir -p $(TRAINER_GFX_DIR)
	$(GFX) $< $@ -clobbersize -version101 -bitdepth 4 -vram -mappingtype 64

$(TRAINER_GFX_DIR)/8_%-01.NCLR:$(TRAINER_GFX_DEPENDENCIES_DIR)/%.png
	@mkdir -p $(TRAINER_GFX_DIR)
	$(GFX) $< $@ -ir -bitdepth 4

$(TRAINER_GFX_DIR)/8_%-02.NCER:$(TRAINER_GFX_DEPENDENCIES_DIR)/%_cell.json
	@mkdir -p $(TRAINER_GFX_DIR)
	$(GFX) $< $@

$(TRAINER_GFX_DIR)/8_%-03.NANR:$(TRAINER_GFX_DEPENDENCIES_DIR)/%_anim.json
	@mkdir -p $(TRAINER_GFX_DIR)
	$(GFX) $< $@

$(TRAINER_GFX_DIR)/8_%-04.NCGR:$(TRAINER_GFX_DEPENDENCIES_DIR)/%_enc.png
	@mkdir -p $(TRAINER_GFX_DIR)
	$(GFX) $< $@ -clobbersize -version101 -bitdepth 4 -scanfronttoback -mwidth 20

$(TRAINER_GFX_NARC): $(TRAINER_GFX_OBJS) $(TRAINER_GFX_DEPENDENCIES)
	$(NARCHIVE) -d $(TRAINER_GFX_DIR) -p $@

OBJS += $(TRAINER_GFX_OBJS)
NARC_FILES += $(TRAINER_GFX_NARC)


# 道具图标
ITEMGFX_DIR := $(BUILD)/itemicon
ITEMGFX_NARC := $(BUILD_NARC)/0/1/8
ITEMGFX_DEPENDENCIES_DIR := data/itemicon
ITEMGFX_DEPENDENCIES := $(ITEMGFX_DEPENDENCIES_DIR)/*

ITEMGFX_SRCS := $(wildcard $(ITEMGFX_DEPENDENCIES_DIR)/*.png)
ITEMGFX_OBJS := $(patsubst $(ITEMGFX_DEPENDENCIES_DIR)/%.png,$(ITEMGFX_DIR)/item_%.NCGR,$(ITEMGFX_SRCS))
ITEMGFX_PALS := $(patsubst $(ITEMGFX_DEPENDENCIES_DIR)/%.png,$(ITEMGFX_DIR)/item_%.NCLR,$(ITEMGFX_SRCS))

$(ITEMGFX_DIR)/item_%.NCGR:$(ITEMGFX_DEPENDENCIES_DIR)/%.png
	$(GFX) $< $@ -clobbersize -version101 -bitdepth 4

$(ITEMGFX_DIR)/item_%.NCLR:$(ITEMGFX_DEPENDENCIES_DIR)/%.png
	$(GFX) $< $@ -ir -bitdepth 4

$(ITEMGFX_NARC): $(ITEMGFX_OBJS) $(ITEMGFX_PALS)
	cp -r rawdata/itemicon/. $(ITEMGFX_DIR)
	$(NARCHIVE) -d $(ITEMGFX_DIR) -p $@ -i output/src/itemtool/item_icon.naix

OBJS += $(ITEMGFX_OBJS) output/src/itemtool/item_icon.naix
NARC_FILES += $(ITEMGFX_NARC)


# Item icon specific targets
ITEMICON_TARGETS := $(ITEMGFX_NARC) $(ITEMGFX_OBJS) $(ITEMGFX_PALS)

.PHONY: itemicon itemicon-clean

itemicon: $(ITEMGFX_NARC)

itemicon-all: $(ITEMICON_TARGETS)

itemicon-clean:
	rm -rf $(ITEMGFX_DIR)
	rm -f $(ITEMGFX_NARC)